package view;

import javax.swing.ImageIcon;

import control.ToWaJoJopoly;


/**
 * This class Handles the creation of imageicons. so that they can be placed within the
 * .jar file later on.
 * 
 * @author Thomas
 *
 */
public class ImageCreator 
{
	/**
	 * This method actually creates the imageicon with the specified path
	 * so instead of
	 * 
	 * new ImageIcon("images/menu.png");
	 * 
	 * use
	 * 
	 * ImageCreator.createImageIcon("image/menu.png");
	 * 
	 * @param path the path to the image
	 * @return The image icon with the specified image
	 */
	public static ImageIcon createImageIcon(String path)
	{
		java.net.URL imageURL = ToWaJoJopoly.class.getClassLoader().getResource(path);
		
		if(imageURL != null)
			return new ImageIcon(imageURL);
		else
		{
			System.err.println("Could not find the specified image: " + path);
			return null;
		}
		
	}

}
